package com.ld.admin.util.daliySentence.impl;

import com.alibaba.fastjson.JSONObject;
import com.ld.admin.util.daliySentence.DaliySentence;
import com.ld.shieldsb.common.core.util.JsoupUtil;

/**
 * 
 * 金山词霸/爱词霸每日一句
 * 
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2020年1月8日 上午11:00:51
 *
 */
public class DaliySentenceIciba implements DaliySentence {
    // 同类型的还有http://dict.cn/
    public static final String URL_ICIBA = "http://open.iciba.com/dsapi"; // 金山词霸

    @Override
    public String getSentence() {
        String content = null;
        JSONObject jsonObj = JsoupUtil.getRemoteURLJson(URL_ICIBA);
        /*       
         * "sid":"3622",
         * "tts":"https://edu-wps.ks3-cn-beijing.ksyun.com/audio/b3ecbafc8a4bfad2fcde184d75b81d74.mp3",
         * "content":"Find a truly original idea. It is the only way I will ever distinguish myself. It is the only way I will ever matter.",
         * "note":"找到真正的原创思想。这是唯一能够使我永远与众不同的方法，是唯一能让我举足轻重的方法。",
         * "love":"198","translation":"新版每日一句",
         * "picture":"https://edu-wps.ks3-cn-beijing.ksyun.com/image/213b880e693178c1a9bb01c5e60ad208.jpg",
         * "picture2":"https://edu-wps.ks3-cn-beijing.ksyun.com/image/31918a2a573cb047957ce94efd74edae.jpg",
         * "caption":"词霸每日一句",
         * "dateline":"2019-12-28","s_pv":"0","sp_pv":"0","tags":null,"fenxiang_img":"http://cdn.iciba.com/web/news/longweibo/imag/2019-12-28.jpg","picture3":"","picture4":""}}*/
        if (jsonObj != null) {
            content = "<img src=\"" + jsonObj.getString("picture") + "\" width='270' >" + "<br/>";
            content += jsonObj.getString("note") + "<br/>" + jsonObj.getString("content");
            content += "【来自<a href='http://open.iciba.com/dsapi' target='_blank'>「爱词霸」</a>】";
        }
        return content;
    }

}
